package main

import "fmt"

func main() {
	m, n := 3, 3
	ops := [][]int{
		{2, 2}, {3, 3},
	}
	fmt.Println(maxCount(m, n, ops))
}

//#link: https://leetcode-cn.com/problems/range-addition-ii/
func maxCount(m int, n int, ops [][]int) int {
	//nums:=make([][]int,m*n)
	//// 寻找执行区域的交集的个数
	//for _,op:=range ops{
	//	for i:=0;i<op[0];i++{
	//		for j:=0;j<op[1];j++{
	//			nums[i][j]++
	//		}
	//	}
	//}
	// 求区域的交集
	i, j := m, n
	for _, op := range ops {
		i = min(i, op[0])
		j = min(j, op[1])
	}
	return i * j

}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
